home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c
- Subject: Re: What is '?' in C mean....?????
- Date: 10 Jan 1996 15:14:42 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan10101442@g7240065.bridge.bst.bls.com>
- References: <4cgsa8$bm2@wumpus.cc.uow.edu.au> <4cvp4d$b6u@news.worldlinx.com>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: stupy@freenet.durham.org's message of 10 Jan 1996 07:16:29 GMT
-
- In article <4cvp4d$b6u@news.worldlinx.com> stupy@freenet.durham.org (Steve Tupy) writes:
- : PAOPENG THEERADECH (tp86@wumpus.cc.uow.edu.au) wrote:
-
- :: Hello to all.
- :: I got something here to ask you guys. I saw some symbol like "?" be
- :: used in some codes. I don't understand what does it mean. I tried to read some
- :: text books but I still cannot find the detail about "?". The codes that I saw
- :: are;
- :: max = x>y ? x:y;
- ::
- :: and
-
- :: printf("%d", x>y ? x:y);
-
- : It tells you that an evaluation is about to happen. If x>y then max = x, if
- : x>y == 0 then max = y. The first value left of the colon is applied only if
- : it evaluates to 1, else the right side is applied.
-
- That should really be: The first value left of the colon is applied
- if the expression doesn't evaluate to 0, else the right side is applied.
- Any non-zero value will cause the left hand side to be evaluated, in C
- anything non-zero is true ;')
-
- Regards
-
- -A.
- --
- | A.Champion |
-